package com.legendframework.core.ioc.exception;

/**
 * Bean转换失败异常
 */
public class BeanNotOfRequiredTypeException extends BeansException {

    /** Bean名称 */
    private final String beanName;

    /** 必须的类型 */
    private final Class<?> requiredType;

    /** 实际的类型 */
    private final Class<?> actualType;


    /**
     * Create a new BeanNotOfRequiredTypeException.
     * @param beanName the name of the bean requested
     * @param requiredType the required type
     * @param actualType the actual type returned, which did not match
     * the expected type
     */
    public BeanNotOfRequiredTypeException(String beanName, Class<?> requiredType, Class<?> actualType) {
        super("Bean :'" + beanName + "' 希望转换的类型是:  '" + requiredType.getName() +
                "' 实际的类型是: '" + actualType.getName() + "'");
        this.beanName = beanName;
        this.requiredType = requiredType;
        this.actualType = actualType;
    }


    public String getBeanName() {
        return this.beanName;
    }

    public Class<?> getRequiredType() {
        return this.requiredType;
    }

    public Class<?> getActualType() {
        return this.actualType;
    }

}
